package com.oyjd.soft;

import java.io.File;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class RemoveNotApk {
	public static void main(String[] args) throws Exception {
		String sql = "select soft_id, sou_path from T_SOFT";
		Connection conn = null;
		List<String> list=new ArrayList<String>();
		try {
			conn = Conn.getConn();
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
			while (rs.next()) {
				String id = rs.getString("soft_id");
				String sou = rs.getString("sou_path");
				if(!new File("/sl/soft/"+sou).exists()){
					list.add(id);
				}
			}
			rs.close();
			stmt.close();
			conn.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (conn != null)
					conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		System.out.println("-------->"+list.size());
		for(String id:list){
			Conn.executeSql("delete from t_soft where soft_id='"+id+"'");
		}
	}
}
